// Copyright (C) 2005 Taylor L. Riché <riche@cs.utexas.edu>
//  
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software 
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// 	$Id: PpfHeaderPrinter.java 34 2005-07-13 16:43:27Z richetl $	
//

import java.io.*;

class PpfHeaderPrinter 
{
    public void print(String name, PpfExits ex, PpfFeatures f, CppIncludes i, 
		      CppData d, CppMethods m) {
	FileOutputStream out = null;
	PrintStream file = null;
	try {
	    out = new FileOutputStream("llt_" + name + ".hh");
	    file = new PrintStream(out);
	}
	catch (FileNotFoundException e) {
	    System.err.println("Specified file " + name + " does not exist.");
	    System.exit(1);
	}

	// Print guards
	file.println("#ifndef __LLT_" + name.toUpperCase() + "_H__");
	file.println("#define __LLT_" + name.toUpperCase() + "_H__");
	file.println();
	
	// Print includes needed by specified features
	if(f != null) {
	    f.printIncludes(file);
	}

	// Print includes specified by programmer
	if(i != null) {
	    i.print(file);
	}

	// Print standard header info
	file.println("#include <PPFunction.h>");
	file.println();
	file.print("class " + name);

	// Print inheritances needed by specified features
	if(f != null) {
	    f.print(file);
	}
	file.println("public PPFunction");
	file.println("{");

	// Print the programmer data
	if(d != null) {
	    d.print(file);
	}
	file.println();

	// Print the programmer methods
	if(m != null) {
	    m.print(file);
	}

	// Print the exit points for the PPF
	if(ex != null) {
	    ex.print(file);
	}

	// Print any private methods needed by the specified features
	if(f != null) {
	    f.printPrivs(file);
	}

	// Below here are publicly visible methods
	printPublic(file);

	// Print the constants defined by the exit points
	if(ex != null) {
	    ex.printPubs(file);
	}
	
	// Print the public methods needed by the specified features
	if(f != null) {
	    f.printPubs(file);
	}

	file.println("}");
	file.println("#endif");
	file.println();
    }

    private void printPublic(PrintStream file) {
	file.println();
	file.println("public:");
	file.println("\tvirtual void processData(const PktData * pkt);");
    }
}


